import apiClient from "@/api/axios.js";
// import {AuthApi} from "@/apis/authApi.js";

class VideoApi {
    static async fetchAllVideo(PageSize, PageNum){
        try {
            const res = await apiClient.post('/primary_video',{
                PageSize: PageSize,
                PageNum: PageNum,
            })
            console.log('获取视频接口成功',res);
            return res;
        } catch (e) {
            console.error('视频接口报错',e);
        }

    }

    // static async fetchHomeUserInfo(){
    //     try {
    //         const res = await apiClient.post('/video/other',{
    //         })
    //         console.log('获取视频接口成功',res);
    //         return res;
    //     } catch (e) {
    //         console.error('视频接口报错',e);
    //     }
    // }

    static async fetchUserVideo(){
        try {
            const res = await apiClient.post('/video/user',{
            })
            console.log('获取视频接口成功',res);
            return res;
        } catch (e) {
            console.error('视频接口报错',e);
        }
    }

    static async fetchOtherUserVideo(user_id){
        try {
            const res = await apiClient.post('/video/other',{
                user_id,
            })
            console.log('获取视频接口成功',res);
            return res;
        } catch (e) {
            console.error('视频接口报错',e);
        }
    }

    static async getVideoUrl(fvid){
        try {
            const res = await apiClient.post('/openVideo',{
                fvid
            })
            console.log('获取视频url接口成功',res);
            return res;
        } catch (e) {
            console.error('获取视频url接口报错',e);
        }
    }

    /**
     * 评论视频接口（一级评论）
     * @param fvid
     * @param commentContent
     * @returns {Promise<void>}
     */
    static async commentVideo(fvid, commentContent){
        try {
            const res = await apiClient.post('/insertComment',{
                video_id: fvid,
                comment_content: commentContent,
            })
            console.log('视频评论接口成功',res);
            return res;
        } catch (e) {
            console.error('视频评论 接口报错',e);
        }
    }
    static async commentVideoComment(commentId, commentContent){
        try {
            const res = await apiClient.post('/insertComment',{
                comment_id: commentId,
                comment_content: commentContent,
            })
            console.log('视频评论接口成功',res);
            return res;
        } catch (e) {
            console.error('视频评论 接口报错',e);
        }
    }

    /**
     * 获取一级评论
     * @param fvid
     * @param PageSize
     * @param PageNum
     * @returns {Promise<axios.AxiosResponse<any>>}
     */
    static async fetchFirstComments(fvid,PageSize,PageNum){
        try {
            const res = await apiClient.post('/comment/first',{
                fvid,
                PageSize,
                PageNum,
            })
            return res;
        } catch (e) {
            console.log('视频一级评论接口报错：',e)
        }
    }

    /**
     * 获取二级评论
     * @param comment_id
     * @param PageSize
     * @param PageNum
     * @returns {Promise<axios.AxiosResponse<any>>}
     */
    static async fetchSecondComments(comment_id,PageSize,PageNum){
        try {
            const res = await apiClient.post('/comment/second',{
                comment_id,
                PageSize,
                PageNum,
            })
            return res;
        } catch (e) {
            console.log('二级评论接口报错：',e)
        }
    }

    // Todo 测试
    // 视频点赞口
    static async VideoLike(fvid){
        try {
            const res = await apiClient.post('videoLike/add',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }
    static async VideoUnlike(fvid){
        try {
            const res = await apiClient.post('videoLike/delete',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }
    static async VideoLikeCheck(fvid){
        try {
            const res = await apiClient.post('videoLike/check',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }
    static async VideoLikeNum(fvid){
        try {
            const res = await apiClient.post('videoLike/num',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }

    // 视频收藏口
    static async VideoFavorite(fvid){
        try {
            const res = await apiClient.post('videoFavorite/add',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }
    static async VideoFavoriteCheck(fvid){
        try {
            const res = await apiClient.post('videoFavorite/check',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }
    static async VideoFavoriteNum(fvid){
        try {
            const res = await apiClient.post('videoFavorite/num',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }



    // Todo 测试
    static async commentLike(comment_id){
        try {
            const res = await apiClient.post('commentLike/add',{
                comment_id,
            })
            return res;
        } catch (e) {
            console.log('评论点赞接口报错：',e)
        }
    }

// Todo 测试
    static async commentUnlike(comment_id){
        try {
            const res = await apiClient.post('commentLike/delete',{
                comment_id,
            })
            return res;
        } catch (e) {
            console.log('评论点赞接口报错：',e)
        }
    }
    static async commentLikeCheck(fvid){
        try {
            const res = await apiClient.post('commentLike/check',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }
    static async commentLikeNum(fvid){
        try {
            const res = await apiClient.post('commentLike/num',{
                fvid,
            })
            return res;
        } catch (e) {
            console.log('视频点赞接口报错：',e)
        }
    }

    static async videoSearch(keyword){
        try {
            const res = await apiClient.post('video/inquire',{
                keyword,
            })
            return res;
        } catch (e) {
            console.log('搜索报错：',e)
        }
    }





}
export default VideoApi;
